from PyQt4 import QtCore, QtGui

#========================================================
#Created on 31/ago/2009
#
#@author: Fabio
# vista dei plaer relativi ai media
#========================================================
class PlayerView( QtGui.QDialog ):
    def __init__( self, parent = None ):
        QtGui.QDialog.__init__( self, parent )
        self.setWindowTitle( 'Suona un Mp3' )
        self.Suona = QtGui.QPushButton( 'Suona' )
        self.Sfoglia = QtGui.QPushButton( 'Sfoglia' )
        self.IP = QtGui.QLabel( 'IP' )
        self.IPEdit = QtGui.QLineEdit()
        self.SfogliaEdit = QtGui.QLineEdit()
        grid = QtGui.QGridLayout()
        grid.setSpacing( 10 )
        grid.addWidget( self.Sfoglia, 1, 0 )
        grid.addWidget( self.SfogliaEdit, 1, 1 )
        grid.addWidget( self.IP, 2, 0 )
        grid.addWidget( self.IPEdit, 2, 1 )
        grid.addWidget( self.Suona, 3, 1 )
        self.setLayout( grid )
        self.resize( 350, 100 )
        self.CreateEvents()

    def CreateEvents( self ):
        self.connect( self.Sfoglia, QtCore.SIGNAL( 'clicked()' ), self.LoadFiles )
        self.connect( self.Suona, QtCore.SIGNAL( 'clicked()' ), self.PlayMusic )

    def LoadFiles( self ):
        fileName = QtGui.QFileDialog.getOpenFileName( self )
        if not fileName.isEmpty():
            self.SfogliaEdit.setText( fileName )
            return

    def PlayMusic( self ):
        MyIp = self.IPEdit.text()
        MySong = self.SfogliaEdit.text()

        # qui il codice per suonare!!!!!

        return
